<?php

class FeedRelation extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
	
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{feed_feed_relation}}';
	}
	
	/*
	 * @ 重新relations
	 *   映射用户表
	 */
	public function relations()
	{
		return array(
			'eventinfo' => array(self::BELONGS_TO, 'FeedList', 'reference_feed_id'),
		);
	}
	
	/*
	 * @插入关系表
	 */
	public function addRelation($reference_feed_id,$referenced_feed_id,$type)
	{
		$this->setIsNewRecord(true);
		$this->reference_feed_id = $reference_feed_id;
		$this->type = $type;
		$this->referenced_feed_id = $referenced_feed_id;
		$this->create_time = time();
		self::model()->save();
	}
}